'''
    发送者，真正去请求大模型的地方
'''

import one_api
from openai import OpenAI

def send(model_name:str,is_stream:bool,ms):
    messages = ms[1]
    # 定义 API 的端点
    api_endpoint = f"http://{one_api.one_api_ip}:{one_api.one_api_port}/v1"
    oneapi_key = f"sk-{one_api.cache_token_list[0]['key']}"

    client = OpenAI(
        api_key= oneapi_key, # 如果您没有配置环境变量，请在此处用您的API Key进行替换
        base_url=api_endpoint,  # 填写DashScope SDK的base_url
    )
    completion = client.chat.completions.create(
        model=model_name,
        messages= messages,
        stream = is_stream
    )
    return ms['0'],completion,ms['2']